home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / dll_gen / drvplus / filetd.frm < prev    next >
Text File  |  1994-06-06  |  17KB  |  553 lines

  1. VERSION 2.00
  2. Begin Form FileTD 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "File Time/Date Changer"
  6.    ClientHeight    =   5730
  7.    ClientLeft      =   1245
  8.    ClientTop       =   1125
  9.    ClientWidth     =   6990
  10.    ControlBox      =   0   'False
  11.    Height          =   6135
  12.    Left            =   1185
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   5730
  17.    ScaleWidth      =   6990
  18.    Top             =   780
  19.    Width           =   7110
  20.    Begin CommandButton CmdDeselectAll 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "&Deselect All"
  23.       Height          =   375
  24.       Left            =   360
  25.       TabIndex        =   1
  26.       Top             =   5040
  27.       Width           =   1575
  28.    End
  29.    Begin CommandButton CmdSelectAll 
  30.       BackColor       =   &H00C0C0C0&
  31.       Caption         =   "&Select All"
  32.       Height          =   375
  33.       Left            =   360
  34.       TabIndex        =   0
  35.       Top             =   4680
  36.       Width           =   1575
  37.    End
  38.    Begin CommandButton ChgDateTime 
  39.       BackColor       =   &H00C0C0C0&
  40.       Caption         =   "Change &Both"
  41.       Height          =   375
  42.       Left            =   5040
  43.       TabIndex        =   6
  44.       Top             =   4680
  45.       Width           =   1575
  46.    End
  47.    Begin CommandButton CmdNewTime 
  48.       BackColor       =   &H00C0C0C0&
  49.       Caption         =   "New T&ime"
  50.       Height          =   375
  51.       Left            =   3480
  52.       TabIndex        =   5
  53.       Top             =   5040
  54.       Width           =   1575
  55.    End
  56.    Begin CommandButton CmdNewDate 
  57.       BackColor       =   &H00C0C0C0&
  58.       Caption         =   "New D&ate"
  59.       Height          =   375
  60.       Left            =   1920
  61.       TabIndex        =   3
  62.       Top             =   5040
  63.       Width           =   1575
  64.    End
  65.    Begin CommandButton CmdChgTime 
  66.       BackColor       =   &H00C0C0C0&
  67.       Caption         =   "Change &Time"
  68.       Height          =   375
  69.       Left            =   3480
  70.       TabIndex        =   4
  71.       Top             =   4680
  72.       Width           =   1575
  73.    End
  74.    Begin CommandButton CmdChgDate 
  75.       BackColor       =   &H00C0C0C0&
  76.       Caption         =   "Change &Date"
  77.       Height          =   375
  78.       Left            =   1920
  79.       TabIndex        =   2
  80.       Top             =   4680
  81.       Width           =   1575
  82.    End
  83.    Begin TextBox Text1 
  84.       Height          =   285
  85.       Left            =   360
  86.       MaxLength       =   11
  87.       TabIndex        =   8
  88.       Text            =   "Text1"
  89.       Top             =   1080
  90.       Width           =   3015
  91.    End
  92.    Begin FileListBox File1 
  93.       Height          =   225
  94.       Hidden          =   -1  'True
  95.       Left            =   4920
  96.       System          =   -1  'True
  97.       TabIndex        =   12
  98.       Top             =   3720
  99.       Visible         =   0   'False
  100.       Width           =   1575
  101.    End
  102.    Begin DirListBox Dir1 
  103.       Height          =   1155
  104.       Left            =   3600
  105.       TabIndex        =   9
  106.       Top             =   240
  107.       Width           =   3015
  108.    End
  109.    Begin DriveListBox Drive1 
  110.       Height          =   315
  111.       Left            =   360
  112.       TabIndex        =   10
  113.       Top             =   240
  114.       Width           =   3015
  115.    End
  116.    Begin ListBox FileList 
  117.       FontBold        =   0   'False
  118.       FontItalic      =   0   'False
  119.       FontName        =   "Fixedsys"
  120.       FontSize        =   9
  121.       FontStrikethru  =   0   'False
  122.       FontUnderline   =   0   'False
  123.       Height          =   1605
  124.       Left            =   360
  125.       MultiSelect     =   1  'Simple
  126.       Sorted          =   -1  'True
  127.       TabIndex        =   11
  128.       Top             =   2760
  129.       Width           =   6255
  130.    End
  131.    Begin CommandButton CmdOkay 
  132.       BackColor       =   &H00C0C0C0&
  133.       Cancel          =   -1  'True
  134.       Caption         =   "O &K A Y"
  135.       Height          =   375
  136.       Left            =   5040
  137.       TabIndex        =   7
  138.       Top             =   5040
  139.       Width           =   1575
  140.    End
  141.    Begin Label LblFileCount 
  142.       Alignment       =   2  'Center
  143.       BackColor       =   &H00C0C0C0&
  144.       Caption         =   "Label2"
  145.       ForeColor       =   &H00800000&
  146.       Height          =   195
  147.       Left            =   2040
  148.       TabIndex        =   17
  149.       Top             =   1920
  150.       Width           =   2895
  151.    End
  152.    Begin Label LblTime 
  153.       Alignment       =   2  'Center
  154.       BackColor       =   &H00C0C0C0&
  155.       Caption         =   "Label3"
  156.       ForeColor       =   &H00000080&
  157.       Height          =   195
  158.       Left            =   3600
  159.       TabIndex        =   16
  160.       Top             =   2400
  161.       Width           =   3015
  162.    End
  163.    Begin Label LblDate 
  164.       Alignment       =   2  'Center
  165.       BackColor       =   &H00C0C0C0&
  166.       Caption         =   "Label3"
  167.       ForeColor       =   &H00000080&
  168.       Height          =   195
  169.       Left            =   360
  170.       TabIndex        =   15
  171.       Top             =   2400
  172.       Width           =   3015
  173.    End
  174.    Begin Label LblFullPath 
  175.       Alignment       =   2  'Center
  176.       BackColor       =   &H00C0C0C0&
  177.       Caption         =   "Label2"
  178.       Height          =   195
  179.       Left            =   360
  180.       TabIndex        =   14
  181.       Top             =   1560
  182.       Width           =   6255
  183.    End
  184.    Begin Label Label1 
  185.       BackStyle       =   0  'Transparent
  186.       Caption         =   "Search Specification:"
  187.       ForeColor       =   &H00800000&
  188.       Height          =   195
  189.       Left            =   360
  190.       TabIndex        =   13
  191.       Top             =   840
  192.       Width           =   3015
  193.    End
  194. End
  195. 'file list box allow multiple selections
  196.  
  197. Dim PathWord As String
  198. Dim FileSpec As String
  199.  
  200. Sub ChgDateTime_Click ()
  201.     ChangeCount% = 0
  202.     Screen.MousePointer = 11
  203.     On Error GoTo BadDrive4
  204.     For i = 0 To FileList.ListCount - 1
  205.         If FileList.Selected(i) = True Then
  206.             ThisDir$ = CurDir$
  207.             pos% = InStr(FileList.List(i), Chr$(9))
  208.             ThisFile$ = Left$(FileList.List(i), pos% - 1)
  209.             ThisFile$ = AddSeparator(ThisDir$) + ThisFile$
  210.             ChgYear% = Val(TheYear)
  211.             ChgMonth% = Val(TheMonth)
  212.             ChgDate% = Val(TheDate)
  213.             x% = SetFileDate(ThisFile$, ChgYear%, ChgMonth%, ChgDate%)
  214.             If x% = False Then
  215.                 Screen.MousePointer = 0
  216.                 MsgBox ThisFile$, 16, "Can Not Change Time"
  217.                 End If
  218.             ChgHours% = Val(TheHours)
  219.             ChgMinutes% = Val(TheMinutes)
  220.             x% = SetFileTime(ThisFile$, ChgHours%, ChgMinutes%)
  221.             If x% = False Then
  222.                 Screen.MousePointer = 0
  223.                 MsgBox ThisFile$, 16, "Can Not Change Time"
  224.                 End If
  225.             ChangeCount% = ChangeCount% + 1
  226.             End If
  227.         Next i
  228.     Screen.MousePointer = 0
  229.     If ChangeCount% = 0 Then
  230.         MsgBox "No files selected to change!", 16, "File Change Error"
  231.         Exit Sub
  232.         Else
  233.         DoFileList
  234.         End If
  235.     Exit Sub
  236. BadDrive4:
  237.     Screen.MousePointer = 0
  238.     MsgBox "Can NOT access drive!", 16, "Drive Error"
  239.     Exit Sub
  240. End Sub
  241.  
  242. Sub CmdChgDate_Click ()
  243.     ChangeCount% = 0
  244.     Screen.MousePointer = 11
  245.     On Error GoTo BadDrive
  246.     For i = 0 To FileList.ListCount - 1
  247.         If FileList.Selected(i) = True Then
  248.             ThisDir$ = CurDir$
  249.             pos% = InStr(FileList.List(i), Chr$(9))
  250.             ThisFile$ = Left$(FileList.List(i), pos% - 1)
  251.             ThisFile$ = AddSeparator(ThisDir$) + ThisFile$
  252.             ChgYear% = Val(TheYear)
  253.             ChgMonth% = Val(TheMonth)
  254.             ChgDate% = Val(TheDate)
  255.             x% = SetFileDate(ThisFile$, ChgYear%, ChgMonth%, ChgDate%)
  256.             If x% = False Then
  257.                 Screen.MousePointer = 0
  258.                 MsgBox ThisFile$, 16, "Can Not Change Time"
  259.                 End If
  260.             ChangeCount% = ChangeCount% + 1
  261.             End If
  262.         Next i
  263.     Screen.MousePointer = 0
  264.     If ChangeCount% = 0 Then
  265.         MsgBox "No files selected to change!", 16, "File Change Error"
  266.         Exit Sub
  267.         Else
  268.         DoFileList
  269.         End If
  270.     Exit Sub
  271. BadDrive:
  272.     Screen.MousePointer = 0
  273.     MsgBox "Can NOT access drive!", 16, "Drive Error"
  274.     Exit Sub
  275. End Sub
  276.  
  277. Sub CmdChgTime_Click ()
  278.     Screen.MousePointer = 11
  279.     ChangeCount% = 0
  280.     On Error GoTo BadDrive2
  281.     For i = 0 To FileList.ListCount - 1
  282.         If FileList.Selected(i) = True Then
  283.             ThisDir$ = CurDir$
  284.             pos% = InStr(FileList.List(i), Chr$(9))
  285.             ThisFile$ = Left$(FileList.List(i), pos% - 1)
  286.             ThisFile$ = AddSeparator(ThisDir$) + ThisFile$
  287.             ChgHours% = Val(TheHours)
  288.             ChgMinutes% = Val(TheMinutes)
  289.             x% = SetFileTime(ThisFile$, ChgHours%, ChgMinutes%)
  290.             If x% = False Then
  291.                 Screen.MousePointer = 0
  292.                 MsgBox ThisFile$, 16, "Can Not Change Time"
  293.                 End If
  294.             ChangeCount% = ChangeCount% + 1
  295.             End If
  296.         Next i
  297.     Screen.MousePointer = 0
  298.     If ChangeCount% = 0 Then
  299.         MsgBox "No files selected to change!", 16, "File Change Error"
  300.         Exit Sub
  301.         Else
  302.         DoFileList
  303.         End If
  304. Exit Sub
  305. BadDrive2:
  306.     Screen.MousePointer = 0
  307.     MsgBox "Can NOT access drive!", 16, "Drive Error"
  308.     Exit Sub
  309. End Sub
  310.  
  311. Sub CmdDeselectAll_Click ()
  312.     Screen.MousePointer = 11
  313.     For i = 0 To FileList.ListCount - 1
  314.         FileList.Selected(i) = False
  315.         Next i
  316.     Screen.MousePointer = 0
  317. End Sub
  318.  
  319. Sub CmdNewDate_Click ()
  320.     Screen.MousePointer = 11
  321.     CalSel.Show 1
  322.     Header = DateSerial(Val(TheYear), Val(TheMonth), Val(TheDate))
  323.     TheDateWord = Format$(Header, "d mmm yyyy")
  324.     LblDate.Caption = "Date to set:  " + TheDateWord
  325. End Sub
  326.  
  327. Sub CmdNewTime_Click ()
  328. Dim TempHours As Integer
  329. Dim TempMinutes As Integer
  330. Dim TempMeridiem As Integer
  331.     Screen.MousePointer = 11
  332.     TimeChg.Show 1
  333.     TempHours = Val(TheHours)
  334.     If TempHours > 11 Then
  335.         TempHours = TempHours - 12
  336.         TempMeridiem = 1
  337.         Else
  338.         TempMeridiem = 0
  339.         End If
  340.     If TempHours = 0 Then TempHours = 12
  341.     TempMinutes = Val(TheMinutes)
  342.     TheTimeWord = Format$(TempHours, "##") + ":" + Format$(TempMinutes, "00")
  343.     If TempMeridiem = 1 Then
  344.         TheTimeWord = TheTimeWord + " pm"
  345.         Else
  346.         TheTimeWord = TheTimeWord + " am"
  347.         End If
  348.     LblTime.Caption = "Time to set:  " + TheTimeWord
  349. End Sub
  350.  
  351. Sub CmdOkay_Click ()
  352.     Unload Me
  353. End Sub
  354.  
  355. Sub CmdSelectAll_Click ()
  356.     Screen.MousePointer = 11
  357.     For i = 0 To FileList.ListCount - 1
  358.         FileList.Selected(i) = True
  359.         Next i
  360.     Screen.MousePointer = 0
  361. End Sub
  362.  
  363. Sub Dir1_Change ()
  364.     Screen.MousePointer = 11
  365.     ChDir dir1.Path
  366.     LblFullPath.Caption = PathWord + LCase$(dir1.Path)
  367.     File1.Path = dir1.Path
  368.     DoFileList
  369.     Screen.MousePointer = 0
  370. End Sub
  371.  
  372. Sub DoFileList ()
  373.     Screen.MousePointer = 11
  374.     On Error GoTo BadFileSpec
  375.     File1.Pattern = FileSpec
  376.     FileList.Clear
  377.     NbrFound% = File1.ListCount
  378.     If NbrFound% = 0 Then
  379.         FileWord$ = "No Matching Files Found"
  380.         ElseIf NbrFound% = 1 Then FileWord$ = "One Matching File Found"
  381.         Else
  382.         FileWord$ = Format$(NbrFound%, "###,##0") + " Matching Files Found"
  383.         End If
  384.     LblFileCount.Caption = FileWord$
  385.     If File1.ListCount = 0 Then
  386.         CmdChgDate.Enabled = False
  387.         CmdChgTime.Enabled = False
  388.         CmdSelectAll.Enabled = False
  389.         CmdDeselectAll.Enabled = False
  390.         ChgDateTime.Enabled = False
  391.         Screen.MousePointer = 0
  392.         Exit Sub
  393.         Else
  394.         CmdChgDate.Enabled = True
  395.         CmdChgTime.Enabled = True
  396.         CmdSelectAll.Enabled = True
  397.         CmdDeselectAll.Enabled = True
  398.         ChgDateTime.Enabled = True
  399.         For i = 0 To File1.ListCount - 1
  400.             TheFileName$ = File1.List(i)
  401.             FullPath$ = CurDir$
  402.             FullPath$ = AddSeparator(FullPath$) + TheFileName$
  403.             TimeStamp$ = FileDateTime(FullPath$)
  404.             TheFileDate$ = Format$(TimeStamp$, "dd mmm yyyy")
  405.             If Left$(TheFileDate$, 1) = "0" Then
  406.                 TheFileDate$ = " " + Right$(TheFileDate$, Len(TheFileDate$) - 1)
  407.                 End If
  408.             TheFileTime$ = Format$(TimeStamp$, "hh:mm am/pm")
  409.             If Left$(TheFileTime$, 1) = "0" Then
  410.                 TheFileTime$ = " " + Right$(TheFileTime$, Len(TheFileTime$) - 1)
  411.                 End If
  412.             TheFileSize$ = Format$(FileLen(FullPath$), "###,###,##0")
  413.             If Len(TheFileSize$) < 11 Then
  414.                 AddSpace$ = Space$(11 - Len(TheFileSize$))
  415.                 Else
  416.                 AddSpace$ = ""
  417.                 End If
  418.             TheFileSize$ = AddSpace$ + TheFileSize$
  419.             TheFileAttr% = GetAttr(FullPath$)
  420.             TheAttr$ = ""
  421.             If (TheFileAttr% And 32) <> 0 Then
  422.                 TheAttr$ = TheAttr$ + "A"
  423.                 Else
  424.                 TheAttr$ = TheAttr$ + "-"
  425.                 End If
  426.             If (TheFileAttr% And 4) <> 0 Then
  427.                 TheAttr$ = TheAttr$ + "S"
  428.                 Else
  429.                 TheAttr$ = TheAttr$ + "-"
  430.                 End If
  431.             If (TheFileAttr% And 2) <> 0 Then
  432.                 TheAttr$ = TheAttr$ + "H"
  433.                 Else
  434.                 TheAttr$ = TheAttr$ + "-"
  435.                 End If
  436.             If (TheFileAttr% And 1) <> 0 Then
  437.                 TheAttr$ = TheAttr$ + "R"
  438.                 Else
  439.                 TheAttr$ = TheAttr$ + "-"
  440.                 End If
  441.             FileList.AddItem TheFileName$ + Chr$(9) + TheFileDate$ + Chr$(9) + TheFileTime$ + Chr$(9) + TheAttr$ + Chr$(9) + TheFileSize$
  442.             Next i
  443.         End If
  444.     Screen.MousePointer = 0
  445.     Exit Sub
  446. BadFileSpec:
  447.     Screen.MousePointer = 0
  448.     Beep
  449.     MsgBox "Invalid File Specification!", 16, "Data Entry Error"
  450.     Text1.SetFocus
  451.     Exit Sub
  452. End Sub
  453.  
  454. Sub Drive1_Change ()
  455.     On Error GoTo SelDrvBad
  456.     Screen.MousePointer = 11
  457.     ChDrive Drive1.Drive
  458.     dir1.Path = Drive1.Drive
  459.     Screen.MousePointer = 0
  460.     Exit Sub
  461. SelDrvBad:
  462.     Screen.MousePointer = 0
  463.     msg$ = "Drive Error " + UCase$(Left$(Drive1.Drive, 1)) + ":"
  464.     response = MsgBox("Can NOT Access Drive!", 21, msg$)
  465.     If response = 4 Then
  466.         Screen.MousePointer = 11
  467.         Resume 0
  468.         End If
  469.     WinRoot
  470.     Exit Sub
  471. End Sub
  472.  
  473. Sub Form_Load ()
  474.     FormCenterScreen Me
  475.     PathWord = "Full Path = "
  476.     
  477.     TheDateWord = Format$(Now, "d mmm yyyy")
  478.     TheMonth = Format$(Now, "m")
  479.     TheDate = Format$(Now, "d")
  480.     TheYear = Format$(Now, "yyyy")
  481.     LblDate.Caption = "Date to set:  " + TheDateWord
  482.  
  483.     TheTimeWord = Format$(Now, "h:mm am/pm")
  484.     TheHours = Format$(Now, "h")
  485.     TheMinutes = Format$(Now, "n")
  486.     LblTime.Caption = "Time to set:  " + TheTimeWord
  487.     
  488.     On Error GoTo BadDrive3
  489.     LblFullPath.Caption = PathWord + LCase$(CurDir$)
  490.     
  491.     ListHscroll FileList, 40
  492.     ReDim tabsets%(4)
  493.     tabsets%(0) = 0
  494.     tabsets%(1) = 16 * 4
  495.     tabsets%(2) = 30 * 4
  496.     tabsets%(3) = 42 * 4
  497.     tabsets%(4) = 44 * 4
  498.     dummy% = OutMessage(FileList.hWnd, 1043, 5, tabsets%(0))
  499.     FileSpec = "*.*"
  500.     Text1.Text = FileSpec
  501.     DoFileList
  502.  
  503.     Screen.MousePointer = 0
  504.     Exit Sub
  505. BadDrive3:
  506.     WinRoot
  507.     Resume Next
  508. End Sub
  509.  
  510. Sub Form_Paint ()
  511.     DoForm3D Me, sunken, 3, 0
  512.     DoForm3D Me, raised, 1, 3
  513.     DoControl3D LblFullPath, sunken, 1
  514.     DoControl3D LblFileCount, sunken, 1
  515.     DoControl3D LblDate, sunken, 1
  516.     DoControl3D LblTime, sunken, 1
  517. End Sub
  518.  
  519. Sub Text1_GotFocus ()
  520.     Text1.SelStart = 0
  521.     Text1.SelLength = Len(Text1.Text)
  522. End Sub
  523.  
  524. Sub Text1_KeyPress (KeyAscii As Integer)
  525.     char = Chr(KeyAscii)
  526.     KeyAscii = Asc(UCase(char))
  527.     If char = "\" Then KeyAscii = 0
  528.     If char = Chr$(34) Then KeyAscii = 0
  529.     If char = Chr$(32) Then KeyAscii = 0
  530.     If char = ":" Then KeyAscii = 0
  531.     If char = Chr$(13) Then
  532.         KeyAscii = 0
  533.         SendKeys "{TAB}"
  534.         Exit Sub
  535.         End If
  536. End Sub
  537.  
  538. Sub Text1_LostFocus ()
  539.     FileSpec = Text1.Text
  540.     DoFileList
  541. End Sub
  542.  
  543. Sub WinRoot ()
  544.     Screen.MousePointer = 11
  545.     WinDir$ = Left$(GetWinDir(), 3)
  546.     Drive1.Drive = WinDir$
  547.     ChDrive WinDir$
  548.     dir1.Path = CurDir$
  549.     LblFullPath.Caption = PathWord + LCase$(dir1.Path)
  550.     Screen.MousePointer = 0
  551. End Sub
  552.  
  553.